package observer.api;

import observer.ChangeMessage;

import java.util.Observable;
import java.util.Observer;

public class AriObserver implements Observer {
    private Observable observable;
    private ChangeMessage changeMessage;

    public AriObserver(Observable observable) {
        this.observable = observable;
        observable.addObserver(this);
    }

    @Override
    public void update(Observable o, Object arg) {
        if(arg instanceof ChangeMessage){
            this.changeMessage = (ChangeMessage) arg;
        }
        showChangeMessage();
    }
    
    public void showChangeMessage(){
        System.out.println("天气观察者接受到新消息: "+ this.changeMessage);
    }
}
